/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jalarbee.web.controller;

import com.jalarbee.web.model.AbstractPageModel;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

/**
 *
 * @author Abdoul
 */
public abstract class AbstractController<T extends AbstractPageModel> implements InitializingBean, Validator {

    public abstract void onBeforeValidation();
    public abstract void onValidationSuccess();
    public abstract void onValidationFailure();
    
    @Override
    public boolean supports(Class<?> type) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public final void validate(Object o, Errors errors) {
        onBeforeValidation();
        try {
            
            onValidationSuccess();
        } catch(Exception e) {
            onValidationFailure();
        }
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
